<template>
    <div style="width:80%">
        <h3>商品信息管理</h3>
        <el-table
        :data="sp"
        style="width: 100%;text-align:center">
            <el-table-column
                prop="_id"
                label="序号"
                >
            </el-table-column>
            <el-table-column
                prop="name"
                label="名称"
            >
            </el-table-column>
            <el-table-column
                prop="price"
                label="价格">
            </el-table-column>
            <el-table-column
                prop="shop"
                label="店铺名称">
            </el-table-column>
            <el-table-column
                prop="describe"
                label="商品描述">
            </el-table-column>
            <el-table-column
                prop="number"
                label="数量">
            </el-table-column>
            <el-table-column
                prop="type"
                label="类型">
            </el-table-column>
            <el-table-column
            fixed="right"
            label="操作"
            width="100">
            <template>
                <el-button @click="edit" type="text" size="small">编辑</el-button>
                <el-button @click="del" type="text" size="small">删除</el-button>
            </template>
            </el-table-column>
        </el-table>
        <div class="block">
            <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage4"
            :page-sizes="[100, 200, 300, 400]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="400">
            </el-pagination>
        
        </div>
    </div>
</template>
    <script>
  export default {
      data() {
      return {
        currentPage1: 5,
        currentPage2: 5,
        currentPage3: 5,
        currentPage4: 4,
        sp:[
            {"_id":0,"name":"鞋子","price":123,"shop":"海澜之家","describe":"加绒","number":40,"type":"鞋靴"}
        ]
      };
    },
      mounted:function(){
        let url="/api/tcb/databasequery?access_token=38_fh29a0Eq_pUPxPPUpvK_DHK5XBNOjDKFFiNpCbMKMxPGW6MdIuzPA7pkmzXFRCdEk66cpZdqW8GlmwAl5s9r6VSGQWgQWKqip_rS-oZYSToD83cBmG2i36F4t5sUT7xKDWFUk4LWQytmjJc0YTHjAAAIDR"
        this.$axios.post( url,
            {
                "env":"minijingdong-6gmzb5oc4447b462",
                "query":"db.collection(\"Shopping\").get()"
            }
        ).then(res=>{
            res=res.data.data;
            res.forEach(item => {
                this.sp.push(JSON.parse(item))
            });
        }).catch(err=>{
            console.log(err)
        })
      },
    methods: {
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
      },
      edit(){
          this.$router.push("/edit")
      },
      del(){
          this.$router.push("/del")
      }
    },
    
  }
</script>
            

    
       